function MyLocalStorage () {}
MyLocalStorage.prototype.getItem = function (key) {
    const now = new Date().getTime();
    const expireTime = localStorage.getItem('expire_' + key) || 0;

    if (expireTime && now > expireTime) {
        this.removeItem(key);
        return undefined;
    }

    try {
        return JSON.parse(localStorage.getItem(key));
    } catch {
        this.removeItem(key);
        return undefined;
    }
}
MyLocalStorage.prototype.setItem = function (key, value, expire) {
    window.localStorage.setItem(key, JSON.stringify(value));
    expire && window.localStorage.setItem('expire_' + key, new Date().getTime() + expire * 1000);
}
MyLocalStorage.prototype.removeItem = function (key) {
    window.localStorage.removeItem(key);
    window.localStorage.removeItem('expire_' + key);
}
MyLocalStorage.prototype.clear = function () {
    window.localStorage.clear();
};
MyLocalStorage.prototype.keys = function () {
    return Object.keys(window.localStorage);
}
 
window.myLocalStorage = new MyLocalStorage();